<template>
  <div id="searchlist"> 


          <el-table :data="datalist" style="width: 100%" :height="dtheight" :header-cell-style="{background:'#4F81BC',color:'white'}"
           :row-class-name="tableRowClassName"  :border="true">

               
                <el-table-column label="帐号"  align='center' width="180">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.telphone }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="姓名"  align='center' width="180">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.nickname }}</span>
                    </template>
                </el-table-column>
                <el-table-column :label="variable_name4"  align='center' width="180">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.manor }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="所属团队"  align='center' width="350">                   
                    <template slot-scope="scope">                   
                        <span >姓名:{{ scope.row.team_name }}手机号:{{ scope.row.team_telphone }}
                        </span>
                    </template>
                </el-table-column>
                 <!-- <el-table-column label="所属运营中心"  align='center' width="180">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.center_name }}</span>
                    </template>
                </el-table-column> -->
                 <el-table-column label="总收益"  align='center' width="180">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.total_profit }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="当前持有"  align='center' width="150">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.hold_count }}</span>
                    </template>
                </el-table-column>
                 <el-table-column :label="'买' + variable_name4 + '天数'"  align='center'  width="150">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.buy_number }}</span>
                    </template>
                </el-table-column>
                 <el-table-column :label="'卖' + variable_name4 + '天数'"  align='center' width="150">                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.sale_number }}</span>
                    </template>
                </el-table-column>
                 <el-table-column :label="'买' + variable_name4 + '详情'"  align='center' width="200">                   
                    <template slot-scope="scope">                   
                          <span  class="see_span" @click="go_but(scope.row)"><i class="el-icon-view el-icon--right"></i></span>
                    </template>
                </el-table-column>
                 <el-table-column label="正常/冻结状态"  align='center' width="150">                   
                    <template slot-scope="scope">     
                        <span v-if="scope.row.frozen_login == 0">正常</span>              
                        <span v-if="scope.row.frozen_login == 1">冻结</span>
                    </template>
                  </el-table-column>
                 <el-table-column label="冻结"  align='center'  fixed="right">                   
                    <template slot-scope="scope">                   
                          <el-switch  
                            :active-value="active1" 
                            :inactive-value="isactive1" 
                            v-model="scope.row.frozen_login" 
                            @change="switchchange1(scope.row)"  
                            active-color="#F5CF49" 
                            inactive-color="#E5E5E5"> 
                         </el-switch> 
                    </template>
                </el-table-column>
                <el-table-column label="自动交割"  align='center'  fixed="right" >                   
                    <template slot-scope="scope">                   
                          <el-switch  
                            :active-value="active2" 
                            :inactive-value="isactive2" 
                            v-model="scope.row.admin_handle_account" 
                            @change="switchchange2(scope.row)"  
                            active-color="#F5CF49" 
                            inactive-color="#E5E5E5"> 
                         </el-switch> 
                    </template>
                </el-table-column>
                <el-table-column :label="variable_name4 + '交割'"  align='center'  fixed="right" width="130px">                   
                    <template slot-scope="scope">                   
                         <el-button size="mini"  type="primary"  v-if="scope.row.admin_handle_account == 1"  plain @click="go_delivery(scope.row)">土地交割</el-button>
                    </template>
                </el-table-column>
                   <el-table-column label="交割记录"  align='center' width="130px"  fixed="right">                   
                    <template slot-scope="scope">                   
                          <el-button size="mini"  type="primary"   plain @click="go_alldetails(scope.row)">交割记录</el-button> 
                    </template>
                </el-table-column>
 
            </el-table>  
   </div>
</template>

<script>

export default {
   name: 'searchlist',
   props:{
      datalist:{  
        //type:Array,
       default:()=>[]
     },
  },
  data () {
    return {
        dtheight:'500',  //窗口高度
        active1:1,
        isactive1:0,
        active2:1,
        isactive2:0,
    }
  },
   components:{

  },
  created(){
     this.dtheight = window.innerHeight - 303
      
  },
  mounted (){
    
  },
  methods: {

    switchchange1(row){
            this.$confirm('是否冻结/解冻, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
         }).then(() => {
                this.post("/member/frozenLogin", {
                    uid:row.uid,
                }).then(res => {

                    if(res.error_code == 0){
                    this.open1(res.result,'success')  //提示框
                    this.$emit('up_list_fun')
                    }else {
                    this.open1(res.message,'warning')
                    }
                    //console.log(res)

             })
        }).catch(() => {
                 this.$emit('up_list_fun') 
        });
    },
    switchchange2(row){
        console.log(row.admin_handle_account)
        if( row.admin_handle_account == 1){
                this.$confirm('是否开启', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                        this.post("/Statistics/coldMemberGoodsStatus", {
                            uid:row.uid,
                        }).then(res => {
                            if(res.error_code == 0){
                            this.open1(res.result,'success')  //提示框
                            this.$emit('up_list_fun')
                            }else {
                            this.open1(res.message,'warning')
                            }

                    })
                }).catch(() => {
                        this.$emit('up_list_fun') 
                });
        }else if(row.admin_handle_account == 0){
               this.$confirm('是否关闭', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
                }).then(() => {
                        this.post("/Statistics/relieveColdMemberGoodsStatus ", {
                            uid:row.uid,
                        }).then(res => {
                            if(res.error_code == 0){
                            this.open1(res.result,'success')  //提示框
                            this.$emit('up_list_fun')
                            }else {
                            this.open1(res.message,'warning')
                            }

                    })
                }).catch(() => {
                        this.$emit('up_list_fun') 
                });
        }
           
    },
    go_but(row){
        this.$router.push({
          path: '/index/landdetails',
          query: {
            name:row.name,
            id:row.uid,
            // type:type,
            // typename:typename
          }
        })
    },
    go_delivery(row){
        this.$router.push({
          path: '/index/deliverydetails',
          query: {
            name:row.telphone,
            id:row.uid,
            // type:type,
            // typename:typename
          }
        })
    },
    go_alldetails(row){
        this.$router.push({
          path: '/index/alldetails',
          query: {
            name:row.telphone,
            id:row.uid,
            // type:type,
            // typename:typename
          }
        })
    },


  }
}
</script>


<style scoped>

</style>